/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.workforce.common.tags;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;

/**
 *
 * @author neo
 */
public class FieldTextTag extends FieldBaseTag {
    private static final long serialVersionUID = -7322719356916450699L;

    protected String size;
    protected String value;
    protected String param;
    protected String max;

    @Override
    public int doStartTag() throws JspException {
        try {
            StringBuffer s = new StringBuffer();
            s.append("<input type=\"text\" ");
            if (sid != null) {
                s.append("id=\"").append(sid).append("\" ");
            }
            if (name != null) {
                s.append("name=\"").append(name).append("\" ");
            } else {
                s.append("name=\"").append(sid).append("\" ");
            }
            if (value != null) {
                s.append(" value=\"").append(value).append("\" ");
            }
            if (size != null) {
                s.append("size=\"").append(size).append("\" ");
            }
            if (sClass != null) {
                s.append("class=\"").append(sClass).append("\" ");
            }
            if (style != null) {
                s.append("style=\"").append(style).append("\" ");
            }
            if (readOnly != null) {
                s.append("readonly=\"").append(readOnly).append("\" ");
            }
            if (max != null) {
                s.append("maxlength=\"").append(max).append("\" ");
            }
            if( onFocus != null ) {
                s.append("onfocus=\"").append(onFocus).append("\" ");
            }
            if( onBlur != null ) {
                s.append("onblur=\"").append(onBlur).append("\" ");
            }
            s.append(">");
            JspWriter out = pageContext.getOut();
            beginTag();
            out.print(s.toString());
            endTag();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return SKIP_BODY;
    }

    public void setSize(String size) {
        this.size = size;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public void setParam(String param) {
        this.param = param;
    }

    public void setMax(String max) {
        this.max = max;
    }
    
    
}
